package zisu.netty.practice.NIO;

import java.nio.ByteBuffer;

/**
 * @Desc: ""
 * @Author: caixiang
 * @DATE: 2020/7/1 9:19
 */
public class NIOByteBufferPutGet {
    public static void main(String[] args) {
        //创建一个Buffer
        ByteBuffer byteBuffer = ByteBuffer.allocate(64);

        //类型化 方式放入数据
        byteBuffer.putInt(100);
        byteBuffer.putLong(999);
        byteBuffer.putChar('才');
        byteBuffer.putShort((short) 4);

        //取出(反转)
        byteBuffer.flip();

        System.out.println();

        //注意： 存进去是什么数据类型 取出来 也要这个数据类型。
        System.out.println(byteBuffer.getInt());
        System.out.println(byteBuffer.getLong());
        System.out.println(byteBuffer.getChar());
        System.out.println(byteBuffer.getShort());
    }
}
